package gameElements;

import java.awt.Color;
import java.util.Random;


/**
 * GSupriseBrick.java
 * 
 * Fredrik Wallenius and Peter Steiner 
 * DP08 - KTH - 2009
 *
 */
public class GSupriseBrick extends GBrick{
	private GController gameController;
	private int surprise;
	
	public GSupriseBrick(GController gC_,Random rnd,double x, double y, Color color, double sizeX,
			double sizeY, Boolean causeBounce, Boolean destroyable, int hitBox) {
		super(x, y, color, sizeX, sizeY, causeBounce, destroyable, hitBox);
		dy=10;
		this.gameController = gC_;
		surprise = rnd.nextInt(4)+1;
	}
	
	/**
	 * Method moves this object in +y direction with dy step
	 */
	public void move() {
		y += dy;
		return;
	}
	
	/**
	 * not used
	 */
	public void hit(){

	}
	
	/**
	 * not used
	 */
	public void setColor(int i){
		
	}
	
	/**
	 * Method performs bonus /punishment action on controller / ball 
	 * depending on value of surprise variable
	 */
	private void surprice(){
		
		switch (surprise) {
		case 1:
			gameController.shrinkController();
			break;

		case 2:
			gameController.entlargenController();
			break;
		case 3:
			gameController.runIncreaseBall();
			break;
		case 4:
			gameController.runDecreaseBall();
			break;
		default:
			break;
		}
	}
	
	/**
	 * Method return value of surprice
	 * @return int 
	 */
	public int getSurprise(){
		return surprise;
	}

	/**
	 * Method controlls if this suprise rectangle has hit controller?
	 * @return
	 */
	public Boolean controllerIntersectCheck() {
				if(this.getBoxRect().intersects( gameController.getBoxRect() )){  //Has it hit controller?
					this.surprice();
					return true;
				}
			return false;
	}

	
	
	/**
	 * Method checks if this surprise is ready to be terminated (yes/no)
	 * @return Boolean true/false
	 */
	public Boolean removeSupriseBrick(){
		//bottom of Gamefield
		double y1 = this.boundBox.y + this.boundBox.height;
		
		if( y > y1 ){
			return true;
		}else{
			return false;
		}
	
	}
	
	protected void constrain(){
	}

}
